#pragma once

#define ARRAY_BLOCK_SIZE 10

#include "GlobalList.h"

struct arrayListFxElement
{
	void* blockAddress;
	int count;
	void* object[ARRAY_BLOCK_SIZE];
};

class DLL_PUBLIC_GMINSTANCE CGlobalArrayList
{
public:
	CGlobalArrayList(void);
	~CGlobalArrayList(void);

public:
	void Add(void* object);
	void Add(int index, void* object);

	void Clear();
	BOOL Contains(void* object);

	void* Get(int index);
	int IndexOf(void* object);
	BOOL IsEmpty();
	void Remove(int index);

	void Set(int index, void* object);
	int Size();
	BOOL readOnly;

private:
	int count;
	CRITICAL_SECTION criticalSection;
	void Lock();
	void UnLock();

	CGlobalList privBlockList;
	arrayListFxElement* NewBlock();
	arrayListFxElement* FindPosition(int index, int& pos, int& blockIndex);
};
